package no.mehdi.usereg.core.listener;

import org.springframework.context.ApplicationListener;
import org.springframework.security.authentication.event.AuthenticationSuccessEvent;
import org.springframework.security.core.userdetails.UserDetails;

public class UserLogingEventListener implements ApplicationListener<AuthenticationSuccessEvent>{
	
	@Override
	public void onApplicationEvent(AuthenticationSuccessEvent appEvent) {
		if (appEvent instanceof AuthenticationSuccessEvent)
	    {
	        AuthenticationSuccessEvent event = (AuthenticationSuccessEvent) appEvent;
	        UserDetails userDetails = (UserDetails) event.getAuthentication().getPrincipal();
	       // System.out.println(userDetails);
	    }
	
		System.out.println("***** Event"+appEvent);
	}
	

}
